package zhaolu.com.example.Delicacy.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import zhaolu.com.example.Delicacy.Entity.ItemBean;
import zhaolu.com.example.Delicacy.R;

public class OrderDetailActivity extends AppCompatActivity {
    private int[] image = {
            R.drawable.dish1, R.drawable.dish2,
            R.drawable.dish3, R.drawable.dish4,
            R.drawable.dish5, R.drawable.dish6,
            R.drawable.dish7, R.drawable.dish8,
            R.drawable.dish9, R.drawable.dish10,
            R.drawable.dish11, R.drawable.dish12,
            R.drawable.dish13
    };
    private TextView tv_title;
    private ImageView iv_image;
    private TextView tv_content;
    private ItemBean itemBean;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.order_detail);
        initView();
        initData();
        initEvent();
    }

    private void initView() {
        tv_title = findViewById(R.id.detail_title);
        iv_image = findViewById(R.id.detail_image);
        tv_content = findViewById(R.id.detail_content);
    }

    private void initData() {
        Intent intent = getIntent();
        itemBean = (ItemBean) intent.getSerializableExtra("item");
    }

    private void initEvent() {
        if (itemBean != null) {
            tv_title.setText(itemBean.getTitle());
            iv_image.setImageResource(image[itemBean.getIdFood() - 1]);
            String str = itemBean.getNote();
            tv_content.setText(str);
        }
    }

}
